package cn.i7baozh.boot.learn;

import a.b.c.d.ImportTestSelector;
import a.b.c.d.MyImportTest1;
import cn.i7baozh.anno.EnableMyTestAnnotation;
import cn.i7baozh.boot.learn.initializer.MyInitializer;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;


/**
 * Import 注解的作用类似于@Component
 * 都会把类加入到spring容器里去
 * <a href="https://www.jb51.net/program/314475mbh.htm">Spring框架的ImportSelector详细解读</a>
 */
@Import({ImportTestSelector.class, MyImportTest1.class})
@EnableMyTestAnnotation
@SpringBootApplication
public class SpringBootLearnMain {
    public static void main(String[] args) {
        //第一种方式
//        SpringApplication.run(SpringBootLearnMain.class);
        //第二种
//        new SpringApplicationBuilder(SpringBootLearnMain.class)
//                .bannerMode(Banner.Mode.CONSOLE)
//                .run(args);
        //第三种
        SpringApplication application = new SpringApplication(SpringBootLearnMain.class);
        //关闭banner
        application.setBannerMode(Banner.Mode.OFF);
        //通过命令行添加的启动参数无法添加到environment中 应用程序无法通过@Value方式获取
        application.setAddCommandLineProperties(false);
        application.addInitializers(new MyInitializer());
        application.run(args);

    }
}